package com.jmitxy.controller;

import com.jmitxy.entity.CommonResult;
import com.jmitxy.entity.Customer;
import com.jmitxy.service.CustService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;

@RestController
@RequestMapping("/customer")
public class CustController
{
    @Autowired
    private CustService custService;

    @GetMapping("/get/{cid}")
    public Customer getCustomerById(@PathVariable("cid") String cid)
    {
        System.out.println(cid);
        try {

        Customer customer=custService.findById(cid);
        return customer;
        }catch (Exception e) {
                e.printStackTrace();
        }
        return null;
           /* if(customer!=null)
            {
                return new CommonResult(200,"查询成功",customer);

            }else{
                return  new CommonResult(444,"查询失败",null);
            }*/

    }
   /* *//*
    * 添加客户的方法
    * 7/25
    * *//*
    @PostMapping("/crete")
    public CommonResult crete( Customer customer)
    {
        customer.setCid("ct"+new Date());
        System.out.println(new Date());
        int result =custService.insert(customer);
        if(result>0){
            return new CommonResult(400,"添加客户成功",result);
        }else{
            return new CommonResult(444,"数据添加失败",null);
        }

    }*/

}
